class Solution
{
public:
    int countDistinctIntegers(vector<int> &nums)
    {
        unordered_set<int> s;
        for (int num : nums)
        {
            s.insert(num);
            s.insert(reverseInt(num));
        }
        return s.size();
    }

    int reverseInt(int n)
    {
        int result = 0;
        while (n)
        {
            result *= 10;
            result += n % 10;
            n /= 10;
        }
        return result;
    }
};